Repository navigation
Migrate scheduled AA event gatherer from Supabase to Turso - #11938
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f977a54c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| AA_MODELS_URL = "https://artificialanalysis.ai/models" | ||
| MODELSDEV_URL = "https://models.dev/api.json" | ||
| II_BENCHMARK = "AA Intelligence Index" | ||
| II_VERSION = "4.3.2" # AA's current index version, as labelled in our data |
There was a problem hiding this comment.
Record the actual AA index version
When the AA page supplies current Intelligence Index scores, every emitted measurement is labeled 4.3.2 regardless of its actual version. The existing load in pm-stack/aggregator/docs/aa-load-2026-11-12/gen_load.py:646–651 explicitly separates previous-index scores from current 5.0.1 scores. A live run therefore inserts current scores into the historical benchmark-version partition, corrupting version-specific comparisons. Determine and validate the source index version before comparing or inserting observations.
Useful? React with 👍 / 👎.
| def differs(row, pin, pout): | ||
| return (row is None or row.get("input_usd_per_1m") != pin | ||
| or row.get("output_usd_per_1m") != pout) |
There was a problem hiding this comment.
Include cache rates in price change detection
For a tracked model whose cache_read or cache_write price changes while its ordinary input/output prices stay unchanged, this predicate returns false and no price event is emitted. Both cache rates are parsed and persisted below, so their stored values remain stale indefinitely despite successful daily runs. Compare all persisted pricing dimensions, and apply the same correction to the AA comparison at lines 276–278, which also ignores cached-input changes.
Useful? React with 👍 / 👎.
| parser=argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument('--live',action='store_true') | ||
| parser.add_argument('--out',default=os.path.join(HERE,'dry_runs')) | ||
| args=parser.parse_args() # Parse before filesystem/credential/network effects. |
There was a problem hiding this comment.
Disable abbreviated options before accepting the live flag
An invocation with the undeclared flag --liv is accepted as --live, enabling database writes instead of reporting a usage error. The installed argparse.ArgumentParser documentation describes allow_abbrev as “Allow long options to be abbreviated unambiguously”; this parser leaves that behavior enabled. Set allow_abbrev=False to enforce the strict declared-argument contract required by AGENTS.md, particularly for the write-enabling flag.
AGENTS.md reference: AGENTS.md:L47-L50
Useful? React with 👍 / 👎.
| "window_kind": "flat", | ||
| "source_kind": r["source_kind"], "source_ref": r["source_ref"], | ||
| "source_date": r["source_date"], "ingest_batch_id": batch_id, |
There was a problem hiding this comment.
Populate effective dates so price updates can become current
When an existing price for the same model and context band has a non-null effective_date, gathered updates cannot supersede it because these rows omit that field, whose schema default is NULL. CURRENT_PRICES orders by effective_date DESC NULLS LAST before considering source_date, so even a newer observation loses to the old dated price. The existing load in pm-stack/aggregator/docs/aa-load-2026-11-12/aa-load-2026-11-12.sql:543–551 creates dated prices, and the UI uses the same ordering in pm-stack/aggregator/src/aa-turso-sql.ts:546. Populate an appropriate effective date so updates become visible instead of being reinserted on every subsequent run.
Useful? React with 👍 / 👎.
| if key not in seen_latest: | ||
| seen_latest.add(key) | ||
| cur_ii[key] = {"value_num": e.get("value_num")} |
There was a problem hiding this comment.
Preserve source-date precedence when selecting current measurements
If an older-source observation is imported after a newer-source observation, this assignment replaces the authoritative current value with the historical value: events is ordered only by ingestion time in read_current(), whereas CURRENT_MEASUREMENTS prioritizes source_date. When the live AA score matches that historical value but differs from the actual current-view winner, the gatherer incorrectly declares it unchanged and never inserts the observation needed to update the current view. Preserve source-date ordering when reconciling identities rather than unconditionally overriding the current-view result with the latest-ingested row.
Useful? React with 👍 / 👎.
Canonicalizes the active standalone #9999 gatherer in scripts, preserving AA/models.dev parsing and diff behavior. Replaces deleted Supabase reads with fleet-platform Hrana; current view ordering matches original source DDL. Commits parent/event inserts atomically, with private UUID intent for ambiguous outcome readback. Strict CLI. Includes narrow systemd service source and schedule registry update. Validation: 8 focused unit tests; production read-only state counts 107 models,1444 measurements,566 current measurements,110 current prices; actual Turso staging atomic insert/defaults and rollback probes pass. No production event writes or service activation yet. Original scratch source unchanged.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.